import React from 'react';
import ReactDOM from 'react-dom';
import 'babel-polyfill';
import { HashRouter } from 'react-router-dom'
import './index.scss';
import App from './App';
import * as serviceWorker from './serviceWorker';
import zh_CN from 'antd/lib/locale-provider/zh_CN'
import 'moment/locale/zh-cn';
import { ConfigProvider } from 'antd';
import { createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import { createLogger } from 'redux-logger'
import thunk from 'redux-thunk'
import reducer from './reducers'
import tool from './utils/commonFuc'
import Session from './utils/Session'

tool.getNowTime();

const middleware = [ thunk ];
if (process.env.NODE_ENV !== 'production') {
  middleware.push(createLogger());
}

// 挂载全局方法和对象
React.Component.prototype.$tool = tool;
React.Component.prototype.$Session = Session;

const store = createStore(
  reducer,
  applyMiddleware(...middleware)
)

ReactDOM.render(
    <HashRouter>
        <ConfigProvider locale={zh_CN}>
            <Provider store={store}>
                <App />
            </Provider>
        </ConfigProvider>
    </HashRouter>,
    document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister();
